Skip to main content
This guide covers the essential operations you’ll use in every PVAC-HFHE application. You’ll learn how to set up the cryptographic system, encrypt data, and decrypt results.

Overview

Every PVAC-HFHE workflow follows these steps:
1

Generate keys

Create public and secret keys using the keygen function
2

Encrypt data

Convert plaintext values to ciphertexts using enc_value
3

Perform operations

Execute homomorphic operations on encrypted data
4

Decrypt results

Recover plaintext values using dec_value

Setting up the cryptographic context

Every PVAC-HFHE application starts by generating cryptographic keys:
The keygen function takes approximately 859ms according to benchmark data. This is a one-time operation per session.

Encrypting values

Use enc_value to encrypt 64-bit unsigned integers:

Example from source

From examples/basic_usage.cpp:59-63:

Decrypting values

The dec_value function returns a field element Fp with two components:
Always use the .lo field of the returned Fp struct to extract the uint64 value. The .hi field contains upper bits of the 127-bit field element.

Testing encryption correctness

Verify your encryption pipeline with special values:
From examples/basic_usage.cpp:66-70:

Performance characteristics

Based on benchmark data:
Fresh ciphertexts are only 42 KB in size, which is 6-85x smaller than comparable RLWE schemes like BFV and CKKS.

Verifying randomness

Encryptions of the same value produce different ciphertexts due to randomization:
From examples/basic_usage.cpp:216-221:

Next steps

Key generation

Deep dive into parameters and key structures

Arithmetic operations

Learn ct_add, ct_mul, and ct_sub